package com.szd.qiongyou20.home.presenter;

import android.content.Context;

import com.szd.qiongyou20.home.bean.HomeListData;
import com.szd.qiongyou20.home.bean.HomeNearData;
import com.szd.qiongyou20.home.modle.LoadHomeData;
import com.szd.qiongyou20.home.modle.LoadData;
import com.szd.qiongyou20.home.modle.LoadHomeListData;
import com.szd.qiongyou20.home.modle.LoadHomeNearData;
import com.szd.qiongyou20.home.view.HomeDataToView;

import java.util.List;

/**
 * Created by SZD on 2016/12/14.
 */

public class HomeListPre {

    // 创建其他两层的几口对象
    private LoadData mLoadData;
    private HomeDataToView mHomeDataToView;

    // 创建构造
    public HomeListPre(HomeDataToView homeDataToView) {
        mHomeDataToView = homeDataToView;
        mLoadData = new LoadHomeData();
    }

    public void loadDataToView(final Context context) {

        mLoadData.HomeListData(context, new LoadHomeListData() {

            @Override
            public void loadDataSuccess(HomeListData homeListData) {
                // 获取顶部ViewPager的数据
                List<HomeListData.DataBean.SlideBean> slide =
                        homeListData.getData().getSlide();
                mHomeDataToView.toViewPager(slide);

                // 获取底部RecyclerView的数据
                List<HomeListData.DataBean.FeedBean.EntryBean> entry =
                        homeListData.getData().getFeed().getEntry();
                mHomeDataToView.toRecyclerView(entry);

                // 获取点评条上的数据
                HomeListData.DataBean.CommentEntryBean comment_entry =
                        homeListData.getData().getComment_entry();
                mHomeDataToView.toComment_entry(comment_entry);
            }

            @Override
            public void loadDataFailed(String string) {

            }
        });

        mLoadData.HomeNearData(context, new LoadHomeNearData() {
            @Override
            public void loadDataSuccess(HomeNearData homeNearData) {
                HomeNearData.DataBean data = homeNearData.getData();
                mHomeDataToView.toNear(data);
            }

            @Override
            public void loadDataFailed(String string) {

            }
        });
    }
}
